/*
Copyright (c) 2012, Qusai Al Abdallah and Omar Fawzi 
 * All rights reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this 
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
package primerdb;

import java.util.Calendar;
import java.text.SimpleDateFormat;

import java.awt.event.*;

import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.*;
import javax.swing.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.io.*;

import java.math.*;

import java.util.StringTokenizer;

import java.net.URLDecoder;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;

import primerdb.persistentTree.AmjadTransferHandler;
import primerdb.persistentTree.NodeMoveTransferHandler;
import primerdb.persistentTree.TreeDropTarget;
import primerdb.persistentTree.UserTreeCellEditor;

public class PrimerDBUI extends javax.swing.JFrame {

    /** Creates new form PrimerDBUI */
    public PrimerDBUI() {

        db = new PrimerDao();

        db.connect();


        //populateTable();



        initComponents();

        initMyComponents();

        refreshTable();

        setResizable(false);
        tblPrimers.setAutoCreateRowSorter(true);
        tblPrimers.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        tblPrimers.getSelectionModel().addListSelectionListener(new RowListener());

    }

    private class RowListener implements ListSelectionListener {

        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting()) {
                return;
            }
            selectedPrimerIndex = tblPrimers.getSelectionModel().getLeadSelectionIndex();
            System.out.println("index of selected primer: " + selectedPrimerIndex);
            if (selectedPrimerIndex >= 0) {
                selectedPrimerID = Integer.parseInt(data.elementAt(selectedPrimerIndex).elementAt(IDXPRIMERID));
                System.out.println(selectedPrimerID);
                loadPrimerData();
            } else {
                for (int i = 0; i < data.size(); i++) {
                    if (Integer.parseInt(data.elementAt(i).elementAt(IDXPRIMERID)) == selectedPrimerID) {
                        selectedPrimerIndex = i;
                        System.out.println("index of new: " + selectedPrimerIndex);
                        tblPrimers.changeSelection(i, 0, false, false);
                        break;
                    }
                }

            }

        }
    }

    /*
     * This method populates the table of primers by 
     * updating the data and header vectors
     * 
     */
    private void populateTable() {
        data = db.getListPrimers(selectedFolderId);
        header = new Vector<String>();
        header.add("ID");
        header.add("Name");
        header.add("Annealing Temp (°C)");
        header.add("Freezer/box");
        header.add("Target Gene");
        header.add("Conc (µM)");
        header.add("Date");
    }

    private void disableViewEditPanel() {

        txtPrimerName.setEditable(false);
        txtPrimerName.setEditable(false);
        txtAnnTemp.setEditable(false);
        txtFreezer.setEditable(false);
        txtTarget.setEditable(false);
        txtConc.setEditable(false);
        txtDate.setEditable(false);
        txtLabel.setEditable(false);
        txtSequence.setEditable(false);
        txtNotes.setEditable(false);
        txtProject.setEditable(false);


        btnSaveNewPrimer.setEnabled(false);
        btnSavePrimer.setEnabled(false);
        btnCancel.setEnabled(false);
        btnDate.setEnabled(false);
        btnAnnTemp.setEnabled(false);
    }

    private void enableViewEditPanel() {

        txtPrimerName.setEditable(true);
        txtPrimerName.setEditable(true);
        txtAnnTemp.setEditable(true);
        txtFreezer.setEditable(true);
        txtTarget.setEditable(true);
        txtConc.setEditable(true);
        txtDate.setEditable(true);
        txtLabel.setEditable(true);
        txtSequence.setEditable(true);
        txtNotes.setEditable(true);
        txtProject.setEditable(true);

        btnSaveNewPrimer.setEnabled(true);
        btnSavePrimer.setEnabled(true);
        btnCancel.setEnabled(true);
        btnDate.setEnabled(true);
        btnAnnTemp.setEnabled(true);
    }

    private void loadPrimerData() {
        System.err.println("Viewing Primer " + selectedPrimerID);

        disableViewEditPanel();

        Primer p = db.getPrimer(selectedPrimerID);

        txtPrimerName.setText(p.getName());
        txtAnnTemp.setText(p.getAnnTemp());
        txtFreezer.setText(p.getFreezer());
        txtTarget.setText(p.getTarget());
        txtConc.setText(p.getConc());
        txtDate.setText(p.getDate());
        txtLabel.setText(p.getLabel());
        txtSequence.setText(p.getSequence());
        txtNotes.setText(p.getNotes());
        txtProject.setText(p.getProject());
    }

    private Primer getTextFields() {
        String name = txtPrimerName.getText();
        String annTemp = txtAnnTemp.getText();
        String freezer = txtFreezer.getText();
        String target = txtTarget.getText();
        String conc = txtConc.getText();
        String date = txtDate.getText();
        String label = txtLabel.getText();
        String sequence = txtSequence.getText();
        String notes = txtNotes.getText();
        String project = txtProject.getText();

        Primer p = new Primer(name, annTemp, freezer, target, conc, date, label, sequence, notes, project, selectedFolderId);

        return p;

    }

    private void saveNewPrimer() {
        Primer p = getTextFields();
        p.setFolderId(selectedFolderId);

        selectedPrimerID = db.newPrimer(p);

        refreshTable();
    }

    private void editPrimer() {

        Primer p = getTextFields();

        p.setId(selectedPrimerID);

        p.setFolderId(selectedFolderId);

        db.editPrimer(p);

        refreshTable();
    }

    private void clearTextFields() {

        txtPrimerName.setText("");
        txtProject.setText("");
        txtAnnTemp.setText("");
        txtFreezer.setText("");
        txtTarget.setText("");
        txtConc.setText("");
        txtDate.setText("");
        txtLabel.setText("");
        txtSequence.setText("");
        txtNotes.setText("");
    }

    private void addPrimerPanel() {
        enableViewEditPanel();

        clearTextFields();

        btnSavePrimer.setEnabled(false);

    }

    private void deletePrimer() {
        db.deletePrimer(selectedPrimerID);

        clearTextFields();

        refreshTable();

    }

    private void refreshTable() {
        populateTable();
        tblPrimers.setModel(new NoEditDefaultTableModel(data, header));

        // -------------------------------------------------------
        // If you want to remove primer ID, uncomment the next line of code
        // --------------------------------------------------------
        tblPrimers.removeColumn(tblPrimers.getColumnModel().getColumn(IDXPRIMERID));       

    }

    public static double round(double d, int decimalPlace) {
        BigDecimal bd = new BigDecimal(Double.toString(d));
        bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
        return bd.doubleValue();
    }

    private void calculateAnnTemp() {

        String strPrimerSequence = txtSequence.getText().toUpperCase();
        strPrimerSequence = strPrimerSequence.replaceAll(" ", "");
        strPrimerSequence = strPrimerSequence.replaceAll("\n", "");

        int intPrimerLength = strPrimerSequence.length();

        char[] strPrimerSequenceNew = new char[intPrimerLength];

        int counter = 0;
        boolean errMessage = false;
        for (int i = 0; i < intPrimerLength; i++) {
            if (strPrimerSequence.charAt(i) != 'A' && strPrimerSequence.charAt(i) != 'T'
                    && strPrimerSequence.charAt(i) != 'C' && strPrimerSequence.charAt(i) != 'G') {
                if (strPrimerSequence.charAt(i) != ' ' && strPrimerSequence.charAt(i) != '\n') {
                    errMessage = true;
                }
            } else {
                strPrimerSequenceNew[counter] = strPrimerSequence.charAt(i);
                counter++;
            }
        }
        if (errMessage) {
            JOptionPane.showMessageDialog(errDialog, "Your sequence contains invalid characters. Invalid characters are omitted in the analysis.", "Warning", JOptionPane.WARNING_MESSAGE);
        }

        intPrimerLength = counter;
        strPrimerSequence = String.copyValueOf(strPrimerSequenceNew, 0, counter);


        int na = 0, nc = 0, ng = 0, nt = 0;

        for (int i = 0; i < intPrimerLength; i++) {
            if (strPrimerSequence.charAt(i) == 'A') {
                na++;
            }
            if (strPrimerSequence.charAt(i) == 'C') {
                nc++;
            }
            if (strPrimerSequence.charAt(i) == 'G') {
                ng++;
            }
            if (strPrimerSequence.charAt(i) == 'T') {
                nt++;
            }
        }

        // Melting temperature computation

        double T1 = 0.0;

        // Method Basic melting temperature, see also german company mwg           

        if (intPrimerLength < 15) {
            T1 = 2 * (na + nt) + 4 * (nc + ng);
        } else {
            try {
                T1 = round(69.3 + (double) 41 * (nc + ng) / ((double) intPrimerLength) - 650.0 / intPrimerLength, 1);
            } catch (Exception e) {
            }
        }

        double annTemp = T1 - 5;

        txtAnnTemp.setText(Double.toString(annTemp));

    }

    /*
     * This method initializes the components that are managed by hand which is
     * mainly the tree of folders. We use the JPersistentTree class
     * 
     */
    private void initMyComponents() {

        fcExport = new JFileChooser() {

            @Override
            public void approveSelection() {
                File f = getSelectedFile();
                if ( f.exists() && getDialogType() == SAVE_DIALOG) {
                    int result = JOptionPane.showConfirmDialog(this, "The file exists, overwrite?", "Existing file", JOptionPane.YES_NO_CANCEL_OPTION);
                    switch (result) {
                        case JOptionPane.YES_OPTION:
                            super.approveSelection();
                            return;
                        case JOptionPane.NO_OPTION:
                            return;
                        case JOptionPane.CLOSED_OPTION:
                            return;
                        case JOptionPane.CANCEL_OPTION:
                            cancelSelection();
                            return;
                    }
                }
                super.approveSelection();
            }
        };
        fcExport.setDialogTitle("Export Primer");
        //fcExport.setApproveButtonText("Save");
        fcExport.setDialogType(JFileChooser.SAVE_DIALOG);

        fcImport = new JFileChooser();
        fcImport.setDialogTitle("Import Primer");
        fcImport.setDialogType(JFileChooser.OPEN_DIALOG);


        FolderStoreAdapter store = new FolderStoreAdapter(db);

        folderTree = new primerdb.persistentTree.JPersistentTree(store);
        
        // we make here the leaf node icon the same as a node icon (they are all folders!)
        DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) folderTree.getCellRenderer();
        cellRenderer.setLeafIcon(cellRenderer.getDefaultClosedIcon());
        folderTree.setCellEditor(
                new UserTreeCellEditor(folderTree, (DefaultTreeCellRenderer) folderTree.getCellRenderer()));

        folderTree.setFont(new java.awt.Font("Arial", 0, 13));
        jScrollPane2.setViewportView(folderTree);
        folderTree.setEditable(true);
        folderTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        folderTree.setShowsRootHandles(true);

        folderTree.addTreeSelectionListener(new MyTreeSelectionListener());
        
        // DnD
        
        NodeMoveTransferHandler handler = new NodeMoveTransferHandler();
        folderTree.setTransferHandler(handler);
        folderTree.setDropTarget(new TreeDropTarget(handler));
        folderTree.setDragEnabled(true);
        
        // initialize selectiong to Root folder
        selectedFolderId = 1;
        changeSelectionTree(1);


        txtSequence.addMouseListener(new ContextMenuMouseListener());
        txtPrimerName.addMouseListener(new ContextMenuMouseListener());
        txtAnnTemp.addMouseListener(new ContextMenuMouseListener());
        txtConc.addMouseListener(new ContextMenuMouseListener());
        txtDate.addMouseListener(new ContextMenuMouseListener());
        txtFreezer.addMouseListener(new ContextMenuMouseListener());
        txtLabel.addMouseListener(new ContextMenuMouseListener());
        txtNotes.addMouseListener(new ContextMenuMouseListener());
        txtProject.addMouseListener(new ContextMenuMouseListener());
        txtTarget.addMouseListener(new ContextMenuMouseListener());

        String os = System.getProperty("os.name").toLowerCase();

        //System.out.println(os);

        ///
        /// CONTROL C -- CONTROL V issue
        ///
      /*
        //if(os.indexOf("mac") >= 0) {     
        InputMap im = (InputMap) UIManager.get("TextField.focusInputMap");
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction);
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction);
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction);
        //}
         */

        searchGUI = new SearchFrame(db, this);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        confirmPane = new javax.swing.JOptionPane();
        errDialog = new javax.swing.JDialog();
        jScrollPane1 = new javax.swing.JScrollPane();
        jSplitPane1 = new javax.swing.JSplitPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        pnlViewEditPrimer = new javax.swing.JPanel();
        lblPrimerName = new javax.swing.JLabel();
        txtPrimerName = new javax.swing.JTextField();
        lblProject = new javax.swing.JLabel();
        txtProject = new javax.swing.JTextField();
        txtLabel = new javax.swing.JTextField();
        lblLabel = new javax.swing.JLabel();
        txtFreezer = new javax.swing.JTextField();
        lblFreezerBox = new javax.swing.JLabel();
        lblSequence = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtSequence = new javax.swing.JTextArea();
        lblAnnTemp = new javax.swing.JLabel();
        lblTarget = new javax.swing.JLabel();
        txtTarget = new javax.swing.JTextField();
        txtAnnTemp = new javax.swing.JTextField();
        btnAnnTemp = new javax.swing.JButton();
        lblNotes = new javax.swing.JLabel();
        btnSaveNewPrimer = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        lblDate = new javax.swing.JLabel();
        txtDate = new javax.swing.JTextField();
        btnDate = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtNotes = new javax.swing.JTextArea();
        lblBasicMethod = new javax.swing.JLabel();
        lblConc = new javax.swing.JLabel();
        txtConc = new javax.swing.JTextField();
        btnSavePrimer = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblPrimers = new javax.swing.JTable();
        btnAddProject = new javax.swing.JButton();
        btnAddPrimer = new javax.swing.JButton();
        btnEditPrimer = new javax.swing.JButton();
        btnDeletePrimer = new javax.swing.JButton();
        btnExportProject = new javax.swing.JButton();
        btnImportProject = new javax.swing.JButton();
        btnDeleteProject = new javax.swing.JButton();
        btnStockSoln = new javax.swing.JButton();
        btnWorkingSoln = new javax.swing.JButton();
        lblPrepare = new javax.swing.JLabel();
        lblPrepare1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lblDesign = new javax.swing.JLabel();
        lblDesign1 = new javax.swing.JLabel();
        btnPcrCalc = new javax.swing.JButton();
        btnSearch2 = new javax.swing.JButton();
        btnAbout = new javax.swing.JButton();
        btnManual = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        btnPrimerDesign = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        javax.swing.GroupLayout errDialogLayout = new javax.swing.GroupLayout(errDialog.getContentPane());
        errDialog.getContentPane().setLayout(errDialogLayout);
        errDialogLayout.setHorizontalGroup(
            errDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        errDialogLayout.setVerticalGroup(
            errDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("PrimerDB");

        jSplitPane1.setDividerLocation(200);
        jScrollPane2 = new javax.swing.JScrollPane();

        jSplitPane1.setLeftComponent(jScrollPane2);

        jSplitPane2.setDividerLocation(150);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        pnlViewEditPrimer.setFont(new java.awt.Font("Arial", 0, 13));
        pnlViewEditPrimer.setMinimumSize(new java.awt.Dimension(60, 60));
        pnlViewEditPrimer.setPreferredSize(new java.awt.Dimension(60, 50));

        lblPrimerName.setFont(new java.awt.Font("Arial", 1, 13));
        lblPrimerName.setText("Primer Name");

        lblProject.setFont(new java.awt.Font("Arial", 1, 13));
        lblProject.setText("Project");

        txtProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtProjectActionPerformed(evt);
            }
        });

        lblLabel.setFont(new java.awt.Font("Arial", 1, 13));
        lblLabel.setText("Tube Label");

        lblFreezerBox.setFont(new java.awt.Font("Arial", 1, 13));
        lblFreezerBox.setText("Freezer/Box");

        lblSequence.setFont(new java.awt.Font("Arial", 1, 13));
        lblSequence.setText("Sequence");

        txtSequence.setColumns(20);
        txtSequence.setLineWrap(true);
        txtSequence.setRows(5);
        jScrollPane4.setViewportView(txtSequence);

        lblAnnTemp.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        lblAnnTemp.setText("Annealing Temperature (°C)");

        lblTarget.setFont(new java.awt.Font("Arial", 1, 13));
        lblTarget.setText("Target Gene");

        btnAnnTemp.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnAnnTemp.setText("Calculate");
        btnAnnTemp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAnnTempActionPerformed(evt);
            }
        });

        lblNotes.setFont(new java.awt.Font("Arial", 1, 13));
        lblNotes.setText("Additional Notes");

        btnSaveNewPrimer.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnSaveNewPrimer.setText("Save As New Primer");
        btnSaveNewPrimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveNewPrimerActionPerformed(evt);
            }
        });

        btnCancel.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        lblDate.setFont(new java.awt.Font("Arial", 1, 13));
        lblDate.setText("Date");

        txtDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDateActionPerformed(evt);
            }
        });

        btnDate.setFont(new java.awt.Font("Arial", 1, 13));
        btnDate.setText("Todays Date");
        btnDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDateActionPerformed(evt);
            }
        });

        txtNotes.setColumns(20);
        txtNotes.setLineWrap(true);
        txtNotes.setRows(5);
        jScrollPane5.setViewportView(txtNotes);

        lblBasicMethod.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        lblBasicMethod.setText("Basic method");

        lblConc.setFont(new java.awt.Font("Arial", 1, 13));
        lblConc.setText("Concentration (µM)");

        txtConc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtConcActionPerformed(evt);
            }
        });

        btnSavePrimer.setFont(new java.awt.Font("Arial", 1, 13));
        btnSavePrimer.setText("Save Primer");
        btnSavePrimer.setEnabled(false);
        btnSavePrimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSavePrimerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlViewEditPrimerLayout = new javax.swing.GroupLayout(pnlViewEditPrimer);
        pnlViewEditPrimer.setLayout(pnlViewEditPrimerLayout);
        pnlViewEditPrimerLayout.setHorizontalGroup(
            pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblAnnTemp, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlViewEditPrimerLayout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addComponent(lblBasicMethod)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtAnnTemp, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnAnnTemp, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlViewEditPrimerLayout.createSequentialGroup()
                                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                            .addComponent(lblSequence, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                                            .addGap(25, 25, 25))
                                        .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                            .addComponent(lblPrimerName)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                        .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                            .addComponent(lblDate, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                        .addComponent(lblFreezerBox)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
                                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                        .addComponent(txtDate, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnDate, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
                                    .addComponent(txtFreezer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
                                    .addComponent(txtPrimerName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE))))
                        .addGap(102, 102, 102)
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblConc, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlViewEditPrimerLayout.createSequentialGroup()
                                .addComponent(lblNotes, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                                .addGap(9, 9, 9))
                            .addComponent(lblProject, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                            .addComponent(lblTarget, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                            .addComponent(lblLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtConc, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                            .addComponent(txtLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                            .addComponent(txtTarget, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                            .addComponent(txtProject, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE))
                        .addGap(10, 10, 10))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlViewEditPrimerLayout.createSequentialGroup()
                        .addGap(380, 380, 380)
                        .addComponent(btnSavePrimer, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSaveNewPrimer, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(21, 21, 21))))
        );
        pnlViewEditPrimerLayout.setVerticalGroup(
            pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlViewEditPrimerLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFreezer)
                            .addComponent(txtLabel)
                            .addComponent(lblLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lblFreezerBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtPrimerName)
                            .addComponent(txtProject)
                            .addComponent(lblPrimerName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lblProject, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                        .addGap(45, 45, 45)))
                .addGap(18, 18, 18)
                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDate)
                    .addComponent(btnDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtTarget, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDate, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                    .addComponent(lblTarget, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                .addComponent(lblNotes, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
                                .addGap(72, 72, 72))
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtConc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblConc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(21, 21, 21))
                    .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(pnlViewEditPrimerLayout.createSequentialGroup()
                                .addComponent(lblSequence, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                                .addGap(72, 72, 72)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAnnTemp, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
                        .addGap(5, 5, 5)
                        .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnAnnTemp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtAnnTemp, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)
                            .addComponent(lblBasicMethod, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE))))
                .addGap(14, 14, 14)
                .addGroup(pnlViewEditPrimerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnSaveNewPrimer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnSavePrimer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(13, 13, 13))
        );

        jSplitPane2.setBottomComponent(pnlViewEditPrimer);

        tblPrimers.setFont(new java.awt.Font("Arial", 0, 13));
        tblPrimers.setPreferredSize(null);
        //tblPrimers.setModel(new NoEditDefaultTableModel(data, header));
        jScrollPane3.setViewportView(tblPrimers);

        jSplitPane2.setLeftComponent(jScrollPane3);

        jSplitPane1.setRightComponent(jSplitPane2);

        jScrollPane1.setViewportView(jSplitPane1);

        btnAddProject.setFont(new java.awt.Font("Arial", 1, 13));
        btnAddProject.setText("Add Folder");
        btnAddProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddProjectActionPerformed(evt);
            }
        });

        btnAddPrimer.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnAddPrimer.setText("Add Primer");
        btnAddPrimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddPrimerActionPerformed(evt);
            }
        });

        btnEditPrimer.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnEditPrimer.setText("Edit Primer");
        btnEditPrimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditPrimerActionPerformed(evt);
            }
        });

        btnDeletePrimer.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnDeletePrimer.setText("Delete Primer");
        btnDeletePrimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeletePrimerActionPerformed(evt);
            }
        });

        btnExportProject.setFont(new java.awt.Font("Arial", 1, 13));
        btnExportProject.setText("Export List of Primers");
        btnExportProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExportProjectActionPerformed(evt);
            }
        });

        btnImportProject.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnImportProject.setText("Import List of Primers");
        btnImportProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImportProjectActionPerformed(evt);
            }
        });

        btnDeleteProject.setFont(new java.awt.Font("Arial", 1, 13));
        btnDeleteProject.setText("Delete Folder");
        btnDeleteProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteProjectActionPerformed(evt);
            }
        });

        btnStockSoln.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnStockSoln.setText("Stock");
        btnStockSoln.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStockSolnActionPerformed(evt);
            }
        });

        btnWorkingSoln.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnWorkingSoln.setText("Working");
        btnWorkingSoln.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWorkingSolnActionPerformed(evt);
            }
        });

        lblPrepare.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        lblPrepare.setText("Prepare a");

        lblPrepare1.setFont(new java.awt.Font("Arial", 1, 13));
        lblPrepare1.setText("solution of the primer");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 13));
        jLabel2.setText("/");

        lblDesign.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        lblDesign.setText("Detailed   ");

        lblDesign1.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        lblDesign1.setText("of the primer");

        btnPcrCalc.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnPcrCalc.setText("Analysis");
        btnPcrCalc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPcrCalcActionPerformed(evt);
            }
        });

        btnSearch2.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
        btnSearch2.setText("Search Primers");
        btnSearch2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearch2ActionPerformed(evt);
            }
        });

        btnAbout.setFont(new java.awt.Font("Arial", 1, 13));
        btnAbout.setText("About");
        btnAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAboutActionPerformed(evt);
            }
        });

        btnManual.setFont(new java.awt.Font("Arial", 1, 13));
        btnManual.setText("Manual");
        btnManual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnManualActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Arial", 1, 13));
        jLabel3.setText("Tools:");

        btnPrimerDesign.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnPrimerDesign.setText("Design");
        btnPrimerDesign.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrimerDesignActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Arial", 1, 13));
        jLabel4.setText("/");

        jButton1.setFont(new java.awt.Font("Arial", 1, 12));
        jButton1.setText("How to cite PrimerDB");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 997, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGap(8, 8, 8)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel3)
                                    .addGap(18, 18, 18)
                                    .addComponent(lblPrepare))
                                .addComponent(lblDesign))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(btnPrimerDesign, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnStockSoln, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(12, 12, 12)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGap(2, 2, 2)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(btnPcrCalc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnWorkingSoln, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblPrepare1, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblDesign1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(203, 203, 203)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(btnManual, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnAbout, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(36, 36, 36))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(btnAddProject, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnDeleteProject, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(96, 96, 96)
                            .addComponent(btnExportProject, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnImportProject, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(89, 89, 89)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(btnSearch2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnAddPrimer, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(btnEditPrimer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnDeletePrimer, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
                            .addContainerGap()))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAddProject)
                    .addComponent(btnDeleteProject)
                    .addComponent(btnEditPrimer)
                    .addComponent(btnAddPrimer)
                    .addComponent(btnExportProject)
                    .addComponent(btnImportProject))
                .addGap(4, 4, 4)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnDeletePrimer)
                    .addComponent(btnSearch2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 505, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnAbout)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnManual)
                            .addComponent(jButton1)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblPrepare1)
                            .addComponent(jLabel2)
                            .addComponent(btnWorkingSoln, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel3)
                            .addComponent(btnStockSoln)
                            .addComponent(lblPrepare))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnPcrCalc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lblDesign1)
                            .addComponent(jLabel4)
                            .addComponent(btnPrimerDesign)
                            .addComponent(lblDesign))))
                .addGap(9, 9, 9))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1016)/2, (screenSize.height-683)/2, 1016, 683);
    }// </editor-fold>//GEN-END:initComponents

    private void btnAnnTempActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnnTempActionPerformed
        calculateAnnTemp();
    }//GEN-LAST:event_btnAnnTempActionPerformed

    // Adding todays date
    private void btnDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateActionPerformed
        Calendar currentDate = Calendar.getInstance();
        SimpleDateFormat formatter =
                new SimpleDateFormat("yyyy/MMM/dd");
        String dateNow = formatter.format(currentDate.getTime());
        txtDate.setText(dateNow);

    }//GEN-LAST:event_btnDateActionPerformed
    public WorkingSolutionGUI workingSoln = new WorkingSolutionGUI();
    private void btnWorkingSolnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWorkingSolnActionPerformed
        // to set jframe in the center of my screen
        workingSoln.setLocationRelativeTo(null);
        // to open workingSoln when clicking "Working" icon    
        workingSoln.setVisible(true);
    }//GEN-LAST:event_btnWorkingSolnActionPerformed

    private void txtDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDateActionPerformed
    }//GEN-LAST:event_txtDateActionPerformed
    public PrimerCalculator primerCalc = new PrimerCalculator();
    private void btnPcrCalcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPcrCalcActionPerformed
        // to set jframe in the center of my screen
        primerCalc.setLocationRelativeTo(null);
        // to open primerCalc when clicking "Analysis" icon
        primerCalc.setVisible(true);
    }//GEN-LAST:event_btnPcrCalcActionPerformed

private void btnSaveNewPrimerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveNewPrimerActionPerformed

    saveNewPrimer();

}//GEN-LAST:event_btnSaveNewPrimerActionPerformed

private void btnSavePrimerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSavePrimerActionPerformed
    editPrimer();
}//GEN-LAST:event_btnSavePrimerActionPerformed

private void btnEditPrimerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditPrimerActionPerformed
    enableViewEditPanel();
}//GEN-LAST:event_btnEditPrimerActionPerformed

private void btnAddPrimerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddPrimerActionPerformed
    addPrimerPanel();
}//GEN-LAST:event_btnAddPrimerActionPerformed

private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
    loadPrimerData();
}//GEN-LAST:event_btnCancelActionPerformed

private void btnDeletePrimerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeletePrimerActionPerformed
    int n = JOptionPane.showConfirmDialog(
            confirmPane, "Are you sure you want to delete the primer?",
            "Delete primer",
            JOptionPane.YES_NO_OPTION);

    if (n == JOptionPane.YES_OPTION) {
        deletePrimer();
    } else {
    }

}//GEN-LAST:event_btnDeletePrimerActionPerformed

private void btnAddProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddProjectActionPerformed

    addFolder();
}//GEN-LAST:event_btnAddProjectActionPerformed

private void btnDeleteProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteProjectActionPerformed

    if (selectedFolderId == 1) {

        JOptionPane.showMessageDialog(confirmPane, "You cannot delete the root folder");

    } else {

        int n = JOptionPane.showConfirmDialog(
                confirmPane, "Are you sure you want to delete the folder?",
                "Delete folder",
                JOptionPane.YES_NO_OPTION);

        if (n == JOptionPane.YES_OPTION) {
            deleteFolder();
            //db.deleteFolder(selectedFolderId);
        } else {
        }
    }


}//GEN-LAST:event_btnDeleteProjectActionPerformed

private void btnExportProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportProjectActionPerformed

    //exportCSV();
    exportXML();

}//GEN-LAST:event_btnExportProjectActionPerformed

private void btnImportProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportProjectActionPerformed
    //importCSV();
    importXML();
}//GEN-LAST:event_btnImportProjectActionPerformed

    private void btnSearch2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearch2ActionPerformed
        // to set jframe in the center of my screen
        searchGUI.setLocationRelativeTo(null);
        // to open SearchGUI when clicking "Search" icon
        searchGUI.setVisible(true);     }//GEN-LAST:event_btnSearch2ActionPerformed

    private void btnManualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnManualActionPerformed


        if (java.awt.Desktop.isDesktopSupported()) {



            String path = PrimerDBUI.class.getProtectionDomain().getCodeSource().getLocation().getPath();
            try {
                String decodedPath = URLDecoder.decode(path, "UTF-8");

                String decodedPathNoJar = (new File(decodedPath)).getParentFile().getPath();

                System.err.println("Decoded path: " + decodedPathNoJar);

                String manualDir = decodedPathNoJar + "/Manual/Manual.pdf";

                File myFile = new File(manualDir);

                java.awt.Desktop.getDesktop().open(myFile);

            } catch (Exception e) {
                System.err.println("Problem in obtaining directory where JAR file is");
            }


        }
    }//GEN-LAST:event_btnManualActionPerformed
    public AboutPDBGUI AboutGUI = new AboutPDBGUI();
    private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed
        // to set jframe in the center of my screen
        AboutGUI.setLocationRelativeTo(null);
        // to open AboutGUI when clicking "About" icon
        AboutGUI.setVisible(true);
    }//GEN-LAST:event_btnAboutActionPerformed

    private void txtProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtProjectActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtProjectActionPerformed

    private void txtConcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtConcActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtConcActionPerformed
    public StockSolution stockSoln = new StockSolution();
    private void btnStockSolnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStockSolnActionPerformed
        // to set jframe in the center of my screen
        stockSoln.setLocationRelativeTo(null);
        // to open AboutGUI when clicking "About" icon
        stockSoln.setVisible(true);
    }//GEN-LAST:event_btnStockSolnActionPerformed
    public DesignPrimerGUI DesignPrimer = new DesignPrimerGUI();
    private void btnPrimerDesignActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrimerDesignActionPerformed
        // to set jframe in the center of my screen
        DesignPrimer.setLocationRelativeTo(null);
        // to open AboutGUI when clicking "About" icon
        DesignPrimer.setVisible(true);
    }//GEN-LAST:event_btnPrimerDesignActionPerformed
    public CiteUsGUI CiteUs = new CiteUsGUI();
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // to set jframe in the center of my screen
        CiteUs.setLocationRelativeTo(null);
        // to open AboutGUI when clicking "About" icon
        CiteUs.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void importCSV() {

        File file = new File("primers.csv");
        //fcImport.setSelectedFile(file); 
        int returnVal = fcImport.showOpenDialog(PrimerDBUI.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = fcImport.getSelectedFile();
            try {
                BufferedReader br = new BufferedReader(new FileReader(file));
                String strLine = null;
                StringTokenizer st = null;
                int lineNumber = 0, tokenNumber = 0;
                while ((strLine = br.readLine()) != null) {
                    lineNumber++;

                    String[] s = strLine.split(",");

                    // If the line is not the header line
                    if (!s[0].equals("Primer Name")) {
                        Primer p = new Primer();
                        try {
                            p.setName(s[0]);
                            p.setProject(s[1]);
                            p.setFreezer(s[2]);
                            p.setLabel(s[3]);
                            p.setDate(s[4]);
                            p.setTarget(s[5]);
                            p.setSequence(s[6]);
                            p.setNotes(s[7]);
                            p.setAnnTemp(s[8]);
                            p.setConc(s[9]);
                        } catch (Exception e) {
                            // ERROR IN PARSING
                            JOptionPane.showMessageDialog(errDialog, "The file you imported is not compatible. Select another file", "Warning", JOptionPane.WARNING_MESSAGE);
                            System.err.println("Problem in file format");
                            break;
                        }
                        p.setFolderId(selectedFolderId);
                        db.newPrimer(p);
                    }
                }

            } catch (FileNotFoundException e) {
                System.err.println("File not found");
                e.printStackTrace();
            } catch (IOException e) {
                System.err.println("General I/O error");
                e.printStackTrace();
            }
        } else {
            System.err.println("Cancelled");
        }


        refreshTable();

    }


    /*
     * This function creates a CSV file that contains a list of primers in the
     * currently selected folder
     * 
     */
    private void exportCSV() {

        // when rec = true, exports the list of all the primers that are in some folder inside the current folder.

        boolean incSubfolders = false;
        boolean onlyNameSeq = false;

        Vector<String> expHeader = new Vector<String>();
        expHeader.add("Primer Name");
        expHeader.add("Project");
        expHeader.add("Freezer/Box");
        expHeader.add("Tube Label");
        expHeader.add("Date");
        expHeader.add("Target Gene");
        expHeader.add("Sequence");
        expHeader.add("Additional Notes");
        expHeader.add("Annealing Temp (degree C)");
        expHeader.add("Conc (uM)");

        Vector<Vector<String>> expData;



        fcExport.setAccessory(new CheckBoxPanel());


        File file = new File("primers.csv");
        fcExport.setSelectedFile(file);


        int returnVal = fcExport.showSaveDialog(PrimerDBUI.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {


            incSubfolders = ((CheckBoxPanel) fcExport.getAccessory()).isIncSubfolders();
           // onlyNameSeq = ((CheckBoxPanel) fcExport.getAccessory()).isOnlyNameSeq();



            if (!incSubfolders) {
                expData = db.exportListPrimers(selectedFolderId);
            } else {
                expData = db.exportRecursiveListPrimers(selectedFolderId);
            }


            file = fcExport.getSelectedFile();
            Writer output = null;
            try {
                output = new BufferedWriter(new FileWriter(file));

                // Writing header
                for (int i = 0; i < expHeader.size(); i++) {
                    String s = expHeader.elementAt(i).toString();
                    if (!onlyNameSeq) {
                        output.write(s);
                        output.write(",");
                    } else if (i == 0 || i == 6) { // name and sequence
                        output.write(s);
                        output.write(",");
                    }
                }
                output.write(";\n");


                for (int j = 0; j < expData.size(); j++) {
                    Vector v = expData.elementAt(j);
                    for (int i = 0; i < v.size(); i++) {
                        String s = v.elementAt(i).toString();
                        s = s.replaceAll(",", "_");

                        if (!onlyNameSeq) {
                            output.write(s);
                            output.write(",");
                        } else if (i == 0 || i == 6) { // name and sequence
                            output.write(s);
                            output.write(",");
                        }
                    }
                    output.write(";\n");
                }

                output.flush();
                output.close();
            } catch (FileNotFoundException fnfe) {
                System.out.println("File Not Found!!");
                fnfe.printStackTrace();
            } catch (IOException ioe) {
                System.out.println("IOException occured!!");
                ioe.printStackTrace();
            }
        } else {
            System.out.println("User cancelled");
        }
        //db.exportListPrimers(selectedFolderId);

        /*
        try {
        //File file = new File("primers/Primer_"+ strPrimerName + ".txt");
        File file = new File("test.txt");
        fc.setSelectedFile(file); 
        int returnVal = fc.showSaveDialog(PrimerCalculator.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
        file = fc.getSelectedFile();
        Writer output = null;
        output = new BufferedWriter(new FileWriter(file));
        output.write(s);
        output.close();
        }
        else {
        System.out.println("Error when writing text file " + returnVal);
        }
        } catch(Exception e) {
        System.out.println("Error when writing text file " + e.toString());
        }
         */
    }

    private void importXML() {
        
        //fcImport.setSelectedFile(file); 
        int returnVal = fcImport.showOpenDialog(PrimerDBUI.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcImport.getSelectedFile();
            XMLImporter importer;
            try {
                importer = new XMLImporter(file, folderTree, db);
                importer.importFile();
                refreshTable();
            } catch (ParserConfigurationException ex) {
                JOptionPane.showMessageDialog(null, "File format error.", "Error", JOptionPane.ERROR_MESSAGE);
            } catch (SAXException ex) {
                JOptionPane.showMessageDialog(null, "File format error.", "Error", JOptionPane.ERROR_MESSAGE);
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(null, "File format error.", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }

    }

    private void exportXML() {

        // when rec = true, exports the list of all the primers that are in some folder inside the current folder.

        File file = new File("primers.xml");
        fcExport.setSelectedFile(file);
        fcExport.setAccessory(new CheckBoxPanel());
        
        int returnVal = fcExport.showSaveDialog(PrimerDBUI.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            
            file = fcExport.getSelectedFile();

            XMLExporter xmlExporter = new XMLExporter(file);

            boolean incSubfolders = false;
            incSubfolders = ((CheckBoxPanel) fcExport.getAccessory()).isIncSubfolders();

            
            boolean shortlisted = false;
            if (!incSubfolders) {
                db.exportPrimers(xmlExporter, xmlExporter.rootElement, selectedFolderId, shortlisted);
            } else {
                db.exportRecursivePrimers(xmlExporter, xmlExporter.rootElement, selectedFolderId, shortlisted);
            }

            xmlExporter.saveDoc();

        } else {
            System.out.println("User cancelled");
        }
    }

    /**
     * add a region to the currently selected tree node (if any). 
     */
    private void addFolder() {
        folderTree.createInSelectedNode(new Folder("new folder"));
    }

    /**
     * remove the currently selected tree node (if any)
     */
    private void deleteFolder() {
        folderTree.deleteSelectedNode();
    }

    /** Add child to the currently selected node. */
//  public DefaultMutableTreeNode addObject(Folder child) {
//        DefaultMutableTreeNode parentNode = null;
//        TreePath parentPath = folderTree.getSelectionPath();
// 
//        if (parentPath == null) {
//            parentNode = rootNode;
//        } else {
//            parentNode = (DefaultMutableTreeNode)
//                         (parentPath.getLastPathComponent());
//        }
// 
//        return addObject(parentNode, child, true);
//    }
// /*
//    public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
//                                            Object child) {
//        return addObject(parent, child, false);
//    }
// */
//    public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
//                                            Folder child, 
//                                            boolean shouldBeVisible) {
//        DefaultMutableTreeNode childNode = 
//                new DefaultMutableTreeNode(child);
//        
//        if (parent == null) {
//            parent = rootNode;
//        }
//        
//        Folder f = (Folder) childNode.getUserObject();
//        
//        
//        treeModel.insertNodeInto(childNode, parent, 
//                                 parent.getChildCount());
//        
// 
//        if (shouldBeVisible) {
//            folderTree.scrollPathToVisible(new TreePath(childNode.getPath()));
//        }
//        return childNode;
//    }
    class WindowCloser extends WindowAdapter {

        public void windowClosing(WindowEvent e) {
            db.disconnect();
        }
    }

    class MyTreeSelectionListener implements TreeSelectionListener {

        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) folderTree.getLastSelectedPathComponent();

            if (node == null) {
                //System.err.println("The node was probably just deleted");
                selectedFolderId = 1;
            } else {
                Folder currentFolder = (Folder) node.getUserObject();

                System.out.println("Current folder is " + Integer.toString(currentFolder.getId()));




                selectedFolderId = currentFolder.getId();

                folderTree.setSelectedId(selectedFolderId);
            }

            refreshTable();

            //System.out.println("Corresponding row is " + folderTree.getSelectionRows()[0]);

            //DefaultMutableTreeNode node1;
            //node1 = (DefaultMutableTreeNode) folderTree.searchRow(selectedFolderId).getLastPathComponent();

            //System.out.println("Id as calculated using search: " + ((Folder) node1.getUserObject()).getId());



        }
    }

    class MyTreeModelListener implements TreeModelListener {

        public void treeNodesChanged(TreeModelEvent e) {
            DefaultMutableTreeNode node;
            node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent());

            /*
             * If the event lists children, then the changed
             * node is the child of the node we've already
             * gotten.  Otherwise, the changed node and the
             * specified node are the same.
             */

            int index = e.getChildIndices()[0];
            node = (DefaultMutableTreeNode) (node.getChildAt(index));


            String newName = (String) node.getUserObject();

            Folder f = new Folder(selectedFolderId, newName);

            node.setUserObject(f);


            System.out.println("The user has finished editing the node.");
            System.out.println("New value: " + node.getUserObject());

        }

        public void treeNodesInserted(TreeModelEvent e) {

            DefaultMutableTreeNode node;
            node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent());

            /*
             * If the event lists children, then the changed
             * node is the child of the node we've already
             * gotten.  Otherwise, the changed node and the
             * specified node are the same.
             */

            int index = e.getChildIndices()[0];
            node = (DefaultMutableTreeNode) (node.getChildAt(index));

            System.out.println("Inserted node " + node.getUserObject());

            Folder f = (Folder) node.getUserObject();


            System.out.println("The user has inserted a node " + Integer.toString(f.getId()));

        }

        public void treeNodesRemoved(TreeModelEvent e) {
        }

        public void treeStructureChanged(TreeModelEvent e) {
        }
    }

    public void changeSelectionTable(int id) {
        for (int i = 0; i < data.size(); i++) {
            if (Integer.parseInt(data.elementAt(i).elementAt(IDXPRIMERID)) == id) {
                selectedPrimerIndex = i;
                System.out.println("index of new: " + selectedPrimerIndex);
                tblPrimers.changeSelection(i, 0, false, false);
                break;
            }
        }
    }

    // change the selection of the folder to the folder "id"
    public void changeSelectionTree(int id) {
        folderTree.setSelectionPath(folderTree.searchItem(id));
        folderTree.setSelectedId(id);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PrimerDBUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PrimerDBUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PrimerDBUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PrimerDBUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new PrimerDBUI().setVisible(true);
            }
        });
    }
    // My variables
    private PrimerDao db;
    private DefaultTableModel model;
    private Vector<Vector<String>> data;
    private Vector<String> header;
    private JFileChooser fcExport;
    private JFileChooser fcImport;
    private int selectedPrimerID = -1;
    private int selectedPrimerIndex = -1;
    private int selectedFolderId = 1;
    protected DefaultMutableTreeNode rootNode;
    protected DefaultTreeModel treeModel;
    private SearchFrame searchGUI;
    private primerdb.persistentTree.JPersistentTree folderTree;
    private javax.swing.JScrollPane jScrollPane2;
    private static int IDXPRIMERID = 0;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAbout;
    private javax.swing.JButton btnAddPrimer;
    private javax.swing.JButton btnAddProject;
    private javax.swing.JButton btnAnnTemp;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnDate;
    private javax.swing.JButton btnDeletePrimer;
    private javax.swing.JButton btnDeleteProject;
    private javax.swing.JButton btnEditPrimer;
    private javax.swing.JButton btnExportProject;
    private javax.swing.JButton btnImportProject;
    private javax.swing.JButton btnManual;
    private javax.swing.JButton btnPcrCalc;
    private javax.swing.JButton btnPrimerDesign;
    private javax.swing.JButton btnSaveNewPrimer;
    private javax.swing.JButton btnSavePrimer;
    private javax.swing.JButton btnSearch2;
    private javax.swing.JButton btnStockSoln;
    private javax.swing.JButton btnWorkingSoln;
    private javax.swing.JOptionPane confirmPane;
    private javax.swing.JDialog errDialog;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JLabel lblAnnTemp;
    private javax.swing.JLabel lblBasicMethod;
    private javax.swing.JLabel lblConc;
    private javax.swing.JLabel lblDate;
    private javax.swing.JLabel lblDesign;
    private javax.swing.JLabel lblDesign1;
    private javax.swing.JLabel lblFreezerBox;
    private javax.swing.JLabel lblLabel;
    private javax.swing.JLabel lblNotes;
    private javax.swing.JLabel lblPrepare;
    private javax.swing.JLabel lblPrepare1;
    private javax.swing.JLabel lblPrimerName;
    private javax.swing.JLabel lblProject;
    private javax.swing.JLabel lblSequence;
    private javax.swing.JLabel lblTarget;
    private javax.swing.JPanel pnlViewEditPrimer;
    private javax.swing.JTable tblPrimers;
    private javax.swing.JTextField txtAnnTemp;
    private javax.swing.JTextField txtConc;
    private javax.swing.JTextField txtDate;
    private javax.swing.JTextField txtFreezer;
    private javax.swing.JTextField txtLabel;
    private javax.swing.JTextArea txtNotes;
    private javax.swing.JTextField txtPrimerName;
    private javax.swing.JTextField txtProject;
    private javax.swing.JTextArea txtSequence;
    private javax.swing.JTextField txtTarget;
    // End of variables declaration//GEN-END:variables
}
